home *** CD-ROM | disk | FTP | other *** search
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • File Name: SLUDGE.c •
- • ---------- •
- • •
- • Copyright © 1990 Apple Computer, Inc. All Rights Reserved •
- • •
- • Description •
- • ----------- •
- • This file contains most of the C language code for the SLUDGE cdev. •
- • •
- • The SLUDGE cdev slows down your mac. It does so by making use of •
- • the jump trace exception found in the 68020 and 68030 processors. •
- • When SLUDGE is turned on, then at every jump trace exception it •
- • executes a tight, inert, loop the number of times specified by the •
- • SLUDGE factor. •
- • •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Include Files •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <Devices.h>
- #include <Scrap.h>
- #include <Lists.h>
- #include "State_Storage_Manager.h"
- #include <ToolUtils.h>
- #include "Parasite_Manager.h"
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Constants that refer to the •
- • controls of the SLUDGE cdev. •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- #define ON_BUTTON 1
- #define OFF_BUTTON 2
- #define USER_ITEM_SCROLL_BAR_COVER 4
- #define THE_SCROLL_BAR 5
- #define ABOUT_BUTTON 6
- #define ENTIRE_ABOUT_BOX 7
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Other constants •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- #define ON true
- #define OFF false
-
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Function Prototypes. •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
-
- void Handle_Scroll_Bar_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems);
- void Init_On_Off_Button_Manager(DialogPtr CPDialog, short numItems, Handle cdevStorage);
- void Turn_On(DialogPtr CPDialog, short numItems, Handle cdevStorage);
- void Turn_Off(DialogPtr CPDialog, short numItems, Handle cdevStorage);
- void Update_Sludge_Factor_Display(Handle cdevStorage);
- void Draw_About_Message();
- void Draw_My_Items(Handle cdevStorage, DialogPtr CPDialog, short numItems);
- void React_To_About_Button_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems);
- void Hide_The_Controls(DialogPtr CPDialog, short numItems);
- void Enable_And_Show_The_Controls(DialogPtr CPDialog, short numItems);
- void Close_About_Box(Handle cdevStorage, DialogPtr CPDialog, short numItems);
- void Draw_My_BackGround();
- void Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(RgnHandle back_region);
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: SLUDGECDEV •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function is the main cdev function for the SLUDGE cdev. For •
- • more info on cdev routines and their parameters, see Inside Mac V. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- pascal Handle
- SLUDGECDEV(short message, short item, short numItems, short CPanelID,
- EventRecord *theEvent, Handle cdevStorage, DialogPtr CPDialog)
- {
-
-
-
- #pragma unused ( theEvent, CPanelID) /* unused formal parameters */
-
- if (message == macDev) return((Handle) 1);
- else if (cdevStorage != nil) {
- switch (message) {
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Initialize cdev •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- case initDev: /* initialize cdev */
- SetUp_State_Storage(&cdevStorage);
-
- if (State_Storage_Allocated(cdevStorage))
- {
- Clear_About_Box_State(cdevStorage);
- Init_On_Off_Button_Manager(CPDialog, numItems, cdevStorage);
-
- Draw_My_Items(cdevStorage, CPDialog, numItems);
- Draw_My_BackGround();
- Turn_Off(CPDialog, numItems, cdevStorage);
-
- if (Get_On_Off_Error_Condition(cdevStorage))
- cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
- }
-
- break;
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Process hitDev. •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- case hitDev:
- switch (item - numItems) {
- case ON_BUTTON:
- if (!In_About_Box_State(cdevStorage))
- {
- Turn_On(CPDialog, numItems, cdevStorage);
- if (Get_On_Off_Error_Condition(cdevStorage))
- cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
- }
- else
- Close_About_Box(cdevStorage, CPDialog, numItems);
- break;
-
- case OFF_BUTTON:
- if (!In_About_Box_State(cdevStorage))
- {
- Turn_Off(CPDialog, numItems, cdevStorage);
- if (Get_On_Off_Error_Condition(cdevStorage))
- cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
- }
- else
- Close_About_Box(cdevStorage, CPDialog, numItems);
- break;
- case ENTIRE_ABOUT_BOX:
- if (In_About_Box_State(cdevStorage))
- Close_About_Box(cdevStorage, CPDialog, numItems);
- break;
-
- case ABOUT_BUTTON:
- React_To_About_Button_Hit(cdevStorage, CPDialog, numItems);
- break;
-
- case USER_ITEM_SCROLL_BAR_COVER:
- if (!In_About_Box_State(cdevStorage))
- Handle_Scroll_Bar_Hit( cdevStorage, CPDialog, numItems);
- else
- Close_About_Box(cdevStorage, CPDialog, numItems);
- break;
-
-
- };
- break;
- case closeDev: /* clean up and dispose */
- break;
- case nulDev:
-
- break;
- case updateDev: /* handle any Update drawing */
- Draw_My_Items(cdevStorage, CPDialog, numItems);
- Draw_My_BackGround();
- break;
- case activDev: /* activate any needed items */
- break;
- case deactivDev: /* deactivate any needed items */
- break;
-
- case keyEvtDev: /* respond to keydown */
- break;
-
- case macDev:
- case undoDev:
- break;
-
- case cutDev:
- case copyDev:
- case pasteDev:
- case clearDev:
- break;
- }
-
- return (cdevStorage);
- } /* cdevStorage != nil */
-
- /*
- ** if cdevStorage = NIL then ControlPanel
- ** will put up memory error
- */
- return (nil);
- }
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Handle_Scroll_Bar_Hit •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This routines handles the manipulations of the scroll bar that is •
- • used to set the SLUDGE factor. Since the control panel would only •
- • call the SLUDGE cdev with a scroll bar event after a mouseUp, and •
- • SLUDGE wanted control after a mouseDown, I implemented a user item •
- • with the same rectangle as the scroll bar and wrote this code to •
- • operate the scroll bar. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Handle_Scroll_Bar_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems)
- {
-
- short itemType;
- ControlHandle itemHandle;
- Rect itemRect;
- Point mouseLoc;
- short scroll_bar_part_code;
- long i;
-
-
- GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- GetMouse(&mouseLoc);
- scroll_bar_part_code = TestControl(itemHandle, mouseLoc);
-
- switch (scroll_bar_part_code) {
- case inUpButton:
- while (StillDown())
- {
- GetMouse(&mouseLoc);
- if ( TestControl(itemHandle, mouseLoc) == inUpButton )
- {
- HiliteControl(itemHandle, inUpButton);
- SetCtlValue(itemHandle, GetCtlValue(itemHandle) - 1);
- Increment_Sludge_Factor(cdevStorage);
- Update_Sludge_Factor_Display(cdevStorage);
- i = TickCount() + 4;
- while (TickCount() < i)
- ;
- }
- else
- HiliteControl(itemHandle, 0);
- }
- HiliteControl(itemHandle, 0);
- break;
- case inDownButton:
- while (StillDown())
- {
- GetMouse(&mouseLoc);
- if ( TestControl(itemHandle, mouseLoc) == inDownButton )
- {
- HiliteControl(itemHandle, inDownButton);
- SetCtlValue(itemHandle, GetCtlValue(itemHandle) + 1);
- Decrement_Sludge_Factor(cdevStorage);
- Update_Sludge_Factor_Display(cdevStorage);
- i = TickCount() + 4;
- while (TickCount() < i)
- ;
- }
- else
- HiliteControl(itemHandle, 0);
- }
- HiliteControl(itemHandle, 0);
- break;
- case inThumb:
- if (TrackControl(itemHandle, mouseLoc, nil) == inThumb)
- {
- Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
- Update_Sludge_Factor_Display(cdevStorage);
- }
- break;
- case inPageUp:
- while (StillDown())
- {
- GetMouse(&mouseLoc);
- if (TestControl(itemHandle, mouseLoc) == inPageUp )
- {
- SetCtlValue(itemHandle, GetCtlValue(itemHandle) - 20);
- Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
- Update_Sludge_Factor_Display(cdevStorage);
- i = TickCount() + 4;
- while (TickCount() < i)
- ;
- }
- }
- break;
- case inPageDown:
- while (StillDown())
- {
- GetMouse(&mouseLoc);
- if (TestControl(itemHandle, mouseLoc) == inPageDown )
- {
- SetCtlValue(itemHandle, GetCtlValue(itemHandle) + 20);
- Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
- Update_Sludge_Factor_Display(cdevStorage);
- i = TickCount() + 4;
- while (TickCount() < i)
- ;
- }
- }
- break;
-
- };
-
- }
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Draw_My_Items •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function is called whenever the SLUDGE cdev gets an updateDev •
- • message. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Draw_My_Items(Handle cdevStorage, DialogPtr CPDialog, short numItems)
- {
- ControlHandle scroll_bar_handle;
- short itemType;
- Rect itemRect;
-
-
-
- if (In_About_Box_State(cdevStorage))
- {
- Hide_The_Controls(CPDialog, numItems);
- Draw_About_Message();
- }
- else
- {
- Update_Sludge_Factor_Display(cdevStorage);
-
- /* draw the scroll bar with the correct thumb position */
- GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &scroll_bar_handle, &itemRect);
- SetCtlValue(scroll_bar_handle, 999 - Get_Sludge_Factor(cdevStorage));
-
- /* draw "SLUDGE Factor:"; I had to draw this string here (instead of making it a DITL item, because of
- SLUDGE's unique about box. */
- MoveTo(105,155);
- DrawString((Str255) "\pSLUDGE Factor:");
- }
- }
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Update_Sludge_Factor_Display •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function draws the numerical SLUDGE factor value. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Update_Sludge_Factor_Display(Handle cdevStorage)
- {
- long local_sludge;
- Rect r;
- char c1,c2,c3;
-
- /* Get the current value */
-
- HLock(cdevStorage);
- local_sludge = ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor;
- HUnlock(cdevStorage);
-
-
- /* calulate character representation of the value */
-
- c1 = (char) ((local_sludge / 100) % 10) + 48;
- c2 = (char) ((local_sludge / 10) % 10) + 48;
- c3 = (char) (local_sludge % 10) + 48;
-
-
- /* Draw the value */
-
- r.left = 180;
- r.right = 210;
- r.top = 140;
- r.bottom = 180;
-
- EraseRect(&r);
- MoveTo(185,155);
- DrawChar(c1);
- DrawChar(c2);
- DrawChar(c3);
- }
-
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Draw_About_Message •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function draws the strings that make up the messages of the •
- • SLUDGE about box. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Draw_About_Message()
- {
- StringHandle current_string;
-
-
-
- current_string = GetString(1);
- MoveTo(105, 90);
- DrawString((Str255) *current_string);
-
- current_string = GetString(2);
- MoveTo(105, 102);
- DrawString((Str255) *current_string);
-
- current_string = GetString(3);
- MoveTo(105, 114);
- DrawString((Str255) *current_string);
-
- current_string = GetString(4);
- MoveTo(105, 126);
- DrawString((Str255) *current_string);
-
- current_string = GetString(5);
- MoveTo(105, 138);
- DrawString((Str255) *current_string);
-
- current_string = GetString(6);
- MoveTo(105, 160);
- DrawString((Str255) *current_string);
-
- current_string = GetString(7);
- MoveTo(105, 172);
- DrawString((Str255) *current_string);
-
- current_string = GetString(8);
- MoveTo(105, 184);
- DrawString((Str255) *current_string);
-
- current_string = GetString(9);
- MoveTo(105, 206);
- DrawString((Str255) *current_string);
-
- current_string = GetString(10);
- MoveTo(105, 228);
- DrawString((Str255) *current_string);
-
-
-
- }
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Close_About_Box •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function erases the message of the about box and re-draws the •
- • SLUDGE controls. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Close_About_Box(Handle cdevStorage, DialogPtr CPDialog, short numItems)
- {
- Rect about_box_rect;
-
- about_box_rect.left = 96;
- about_box_rect.right = 308;
- about_box_rect.top = 74;
- about_box_rect.bottom = 239;
-
- Clear_About_Box_State(cdevStorage);
- EraseRect(&about_box_rect);
- Enable_And_Show_The_Controls(CPDialog, numItems);
- DrawControls(CPDialog);
- Draw_My_Items(cdevStorage, CPDialog, numItems);
- }
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: React_To_About_Button_Hit •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • If the about box is currently displayed, this function calls •
- • Close_About_Box, otherwise it scrolls away the SLUDGE controls •
- • and draws the about box. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void React_To_About_Button_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems)
- {
- Rect scrolling_rect;
- RgnHandle My_Scrolling_Update_Region;
- RgnHandle Current_Clip_Region;
- long i,j;
-
-
- if (In_About_Box_State(cdevStorage))
- Close_About_Box(cdevStorage, CPDialog, numItems);
- else
- {
- scrolling_rect.left = 96;
- scrolling_rect.right = 308;
- scrolling_rect.top = 74;
- scrolling_rect.bottom = 239;
-
- Set_About_Box_State(cdevStorage);
-
-
-
- My_Scrolling_Update_Region = NewRgn();
- Current_Clip_Region = NewRgn();
-
- for (j=0; j < 57; j++)
- {
- ScrollRect(&scrolling_rect, 0, 3, My_Scrolling_Update_Region);
-
- GetClip(Current_Clip_Region);
- SetClip(My_Scrolling_Update_Region);
- Draw_About_Message();
-
- SetClip(Current_Clip_Region);
-
- scrolling_rect.top = scrolling_rect.top + 3;
-
- i = TickCount() + 1;
- while (TickCount() < i)
- ;
- }
-
- DisposeRgn(My_Scrolling_Update_Region);
- DisposeRgn(Current_Clip_Region);
-
- }
- }
-
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Hide_The_Controls •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function marks the controls of the SLUDGE cdev as hidden so •
- • they are not displayed by the Control Panel during an update event. •
- • You don't want them displayed when the SLUDGE cdev is in the about •
- • box state. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Hide_The_Controls(DialogPtr CPDialog, short numItems)
- {
- short itemType;
- ControlHandle itemHandle;
- Rect itemRect;
-
- GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HideControl(itemHandle);
-
- GetDItem(CPDialog, ON_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HideControl(itemHandle);
-
- GetDItem(CPDialog, OFF_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HideControl(itemHandle);
-
- }
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Enable_And_Show_The_Controls •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function marks the controls of the SLUDGE cdev as visible so •
- • they are displayed by the Control Panel during an update event. •
- • You don't want them displayed when the SLUDGE cdev is not in the •
- • about box state. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Enable_And_Show_The_Controls(DialogPtr CPDialog, short numItems)
- {
- short itemType;
- ControlHandle itemHandle;
- Rect itemRect;
-
- GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HiliteControl(itemHandle, 0);
- ShowControl(itemHandle);
-
- GetDItem(CPDialog, ON_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HiliteControl(itemHandle, 0);
- ShowControl(itemHandle);
-
- GetDItem(CPDialog, OFF_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
- HiliteControl(itemHandle, 0);
- ShowControl(itemHandle);
-
- }
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Draw_My_BackGround •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function draws the background of the SLUDGE cdev. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Draw_My_BackGround()
- {
- Rect nrctRect, shadow_rect;
- RgnHandle temp1_region, temp2_region;
- RGBColor current_color, op_color;
-
- current_color.red = 0;
- current_color.green = 0;
- current_color.blue = 0;
- RGBForeColor(¤t_color);
- PenNormal();
-
- temp1_region = NewRgn();
- temp2_region = NewRgn();
-
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Frame the rects containing the •
- • SLUDGE controls. (Theses rects are •
- • not 'nrct's because I wanted to •
- • draw my fancy background.) •
- • AND calculate the region that is •
- • everything but these rects. I will •
- • fill this region with the background•
- • pattern. •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- SetRectRgn(temp1_region,89,1, 321, 254); /* all of the cpanel, used by Sludge */
-
-
- nrctRect.left = 94; /* The big rect with main controls */
- nrctRect.right = 310;
- nrctRect.top = 73;
- nrctRect.bottom = 241;
-
- FrameRect(&nrctRect);
-
- RectRgn(temp2_region, &nrctRect);
- DiffRgn(temp1_region, temp2_region, temp1_region);
-
-
- nrctRect.left = 94; /* The rect with SLUDGE title */
- nrctRect.right = 235;
- nrctRect.top = 3;
- nrctRect.bottom = 67;
-
- FrameRect(&nrctRect);
-
- RectRgn(temp2_region, &nrctRect);
- DiffRgn(temp1_region, temp2_region, temp1_region);
-
-
- nrctRect.left = 241; /* The rect with the 'About' button */
- nrctRect.right = 310;
- nrctRect.top = 3;
- nrctRect.bottom = 67;
-
- FrameRect(&nrctRect);
-
- RectRgn(temp2_region, &nrctRect);
- DiffRgn(temp1_region, temp2_region, temp1_region);
-
-
- /* Draw interesting stuff here */
-
- Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(temp1_region);
-
- /*••••••••••••••••••••••••••••••••••••••••••
- • •
- • Shadow the rectangles to give offset•
- • look. •
- • •
- ••••••••••••••••••••••••••••••••••••••••••*/
- current_color.red = 0x2000;;
- current_color.green = 0x2000;
- current_color.blue = 0x2000;
- RGBForeColor(¤t_color);
-
- op_color.red = 0x8000;
- op_color.green = 0x8000;
- op_color.blue = 0x8000;
- OpColor(&op_color);
-
- PenSize(1,1);
- PenMode(blend);
-
-
- /* bottom of rect with main controls */
- shadow_rect.left = 96;
- shadow_rect.right = 310;
- shadow_rect.top = 241;
- shadow_rect.bottom = 244;
- PaintRect(&shadow_rect);
-
- /* side of rect with main controls */
- shadow_rect.left = 310;
- shadow_rect.right = 313;
- shadow_rect.top = 75;
- shadow_rect.bottom = 244;
- PaintRect(&shadow_rect);
-
-
- /* bottom of rect with SLUDGE title */
- shadow_rect.left = 96;
- shadow_rect.right = 235;
- shadow_rect.top = 67;
- shadow_rect.bottom = 70;
- PaintRect(&shadow_rect);
-
- /* side of rect with SLUDGE title */
- shadow_rect.left = 235;
- shadow_rect.right = 238;
- shadow_rect.top = 5;
- shadow_rect.bottom = 70;
- PaintRect(&shadow_rect);
-
-
- /* bottom of rect with about button */
- shadow_rect.left = 243;
- shadow_rect.right = 310;
- shadow_rect.top = 67;
- shadow_rect.bottom = 70;
- PaintRect(&shadow_rect);
-
- /* side of rect with about button */
- shadow_rect.left = 310;
- shadow_rect.right = 313;
- shadow_rect.top = 5;
- shadow_rect.bottom = 70;
- PaintRect(&shadow_rect);
-
-
-
- current_color.red = 0;
- current_color.green = 0;
- current_color.blue = 0;
- RGBForeColor(¤t_color);
- PenNormal();
-
-
-
- }
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Identifier: Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern •
- • ----------- •
- • •
- • Description •
- • ----------- •
- • This function fills the background of the SLUDGE cdev with the •
- • current desktop pattern. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 2/20/90 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(RgnHandle back_region)
- {
-
- Ptr SPMisc2; /* Inside Mac xref */
-
- SPMisc2 = (Ptr) 0x20B;
-
- /* If bit 7 is set for this byte then, a color PixPattern is the background */
- /* pattern, otherwise the b&w pattern at $A3C is the background pattern */
-
- if (*SPMisc2 < 0)
- FillCRgn(back_region, GetPixPat(16)); /* Use 'ppat'=16 resource in system file */
- else
- FillRgn(back_region, (Pattern) 0xA3C); /* Use the 'pattern' at location $A3C */
- }
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Function Name: Update_On_Off_Button_Display •
- • -------------- •
- • •
- • Description •
- • ----------- •
- • This command sets the visible condition of the On/Off buttons based •
- • on the current value from the state storage manager. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 7/20/89 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Update_On_Off_Button_Display(DialogPtr CPDialog, short numItems, Handle cdevStorage)
- {
- short itemType;
- Rect itemRect;
- Handle itemHand;
-
- int On_Off_Value = Get_ONFF_Value(cdevStorage);
-
- if (!Get_On_Off_Error_Condition(cdevStorage))
- {
- if (On_Off_Value == ON)
- {
- GetDItem(CPDialog, numItems + ON_BUTTON, &itemType, &itemHand, &itemRect);
- SetCtlValue( (ControlHandle) itemHand, 1);
-
- GetDItem(CPDialog, numItems + OFF_BUTTON, &itemType, &itemHand, &itemRect);
- SetCtlValue( (ControlHandle) itemHand, 0);
-
- }
- else
- {
- GetDItem(CPDialog, numItems + ON_BUTTON, &itemType, &itemHand, &itemRect);
- SetCtlValue( (ControlHandle) itemHand, 0);
-
- GetDItem(CPDialog, numItems + OFF_BUTTON, &itemType, &itemHand, &itemRect);
- SetCtlValue( (ControlHandle) itemHand, 1);
-
- }
- }
- }
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Function Name: Init_On_Off_Button_Manager •
- • -------------- •
- • •
- • Description •
- • ----------- •
- • This command performs any initialization actions for the On/Off •
- • buttons, including calling the button update command and setting •
- • the On/Off error condition to false. •
- • • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 7/20/89 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Init_On_Off_Button_Manager(DialogPtr CPDialog, short numItems, Handle cdevStorage)
- {
- Set_On_Off_Error_Condition(cdevStorage, false);
- Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
- }
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Function Name: Turn_On •
- • -------------- •
- • •
- • Description •
- • ----------- •
- • This command is called when the SLUDGE CDEV receives •
- • a hitDev message for the On button. •
- • •
- • It starts the SLUDGING. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 7/20/89 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Turn_On(DialogPtr CPDialog, short numItems, Handle cdevStorage)
- {
- int On_Off_Value = Get_ONFF_Value(cdevStorage);
-
- if (!Get_On_Off_Error_Condition(cdevStorage))
- {
- if (On_Off_Value == OFF)
- {
- Set_ONFF_Value(cdevStorage, ON);
- if (!Get_On_Off_Error_Condition(cdevStorage))
- {
- Install(cdevStorage, Get_Sludge_Factor(cdevStorage));
- Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
- }
- }
- }
- }
-
-
-
-
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- • •
- • Function Name: Turn_Off •
- • -------------- •
- • •
- • Description •
- • ----------- •
- • This command is called when the SLUDGE CDEV receives •
- • a hitDev message for the Off button. •
- • •
- • It stops the SLUDGING. •
- • •
- • History •
- • ------- •
- • •
- • Author Date Description •
- • ------------------------------------------------------------------ •
- • Kevin McEntee 7/20/89 Original Implementation •
- • •
- • •
- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- void Turn_Off(DialogPtr CPDialog, short numItems, Handle cdevStorage)
- {
- int On_Off_Value = Get_ONFF_Value(cdevStorage);
-
- if (!Get_On_Off_Error_Condition(cdevStorage))
- {
- if (On_Off_Value == ON)
- {
- Set_ONFF_Value(cdevStorage, OFF);
- if (!Get_On_Off_Error_Condition(cdevStorage))
- {
- remove(cdevStorage);
- Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
- }
- }
- }
- }
-